import BaseService from "./BaseService";

/**
 * 产品service
 */
export default class SmsService extends BaseService {

  constructor() {
    super();
  }

  /**
   * 返回list
   */
  send(phone) {
    const url = `${this.host}/sms/verify-code?mobile=${phone}`;
    return this.post(url).then(data => data != '' ? data : Promise.reject('SMS_SEND_FAIL'));
  }

  bindUser(unionid, mobile, code, token, openid) {
  const url = `${this.host}/login?unionid=${unionid}&mobile=${mobile}&code=${code}&token=${token}&openid=${openid}`;
    return this.post(url);
  }

  confirmCode(confirm) {
    const url = `${this.host}/sms/comfirm-code`;
    return this.post(url, confirm);
  }
}
